<template>
	<view>
		<view class="block">
			<view class="title" style="font-size: 36rpx;font-weight: bold;text-shadow:#cacaca 1px 1px 2px">
				开一家属于您的线上回收店
			</view>
		<!-- 	<view class="content">
				<view class="my">
					立即升级 享受分销权益！
				</view>
			</view> -->
		</view>
		<view class="block">
			<view class="content">
				<view class="item" v-for="(item,index) in amountList" :key="index" @tap="select(item.price,item.id)"
					:class="{'on':item.price == inputAmount}">
					<view class="card-box x-end x-bc">
						<view class="left y-start">
							<text class="title">入驻衣之光</text>
							<view v-if="item.price>1000">
							<text class="money-num">￥{{item.price}}</text>
							</view> 
							<view v-if="item.price<1000">
							<text class="money-num">￥{{item.price}}</text>
		<!-- 					<view class="res">
								<view class="checkbox" @click="isDefaultChange()">
									<checkbox style="transform:scale(0.4)" :checked="checked" />
								</view>
								点击同意<view @tap="toPage()">《合伙人合作协议》</view>
							</view> -->
							</view>
						</view>
						<button class="cu-btn cash-btn">{{item.name}}</button>
					</view>
				</view>
			</view>
		</view>
		<view class="block">
			<view class="title">
				选择支付方式
			</view>
			<view class="content">
				<view class="pay-list">
					<view class="row" @tap="paytype='wxpay'">
						<view class="left">
							<image src="/static/img/wxpay.png"></image>
						</view>
						<view class="center">
							微信支付
						</view>
						<view class="right">
							<radio style="transform:scale(0.8)" :checked="paytype=='wxpay'" color="#2d95fd" />
						</view>
					</view>
				<!-- 	<view class="row" @tap="paytype='alipay'">
						<view class="left">
							<image src="/static/img/alipay.png"></image>
						</view>
						<view class="center">
							支付宝支付
						</view>
						<view class="right">
							<radio style="transform:scale(0.8)" :checked="paytype=='alipay'" color="#2d95fd" />
						</view>
					</view> -->

				</view>
			</view>
		</view>
		<view class="save">
			<view class="btn" @tap="doDeposit">立即支付</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputAmount: '', //金额
				member_type: '',
				amountList: [
				],
				paytype: 'wxpay' ,//支付类型
				// checked: false,
			};
		},
		onLoad() {
				this.$api.http.get('user-member', {
				}).then(res => {
					this.amountList =[]
					if (res.code == 1&&res.data.list.length!=0) {
						res.data.list.forEach((item) => {
							if(item.id!=3){
								this.amountList.push(item)
							}
						})
					
					}
				})
		},
		methods: {
			select(amount, type) {
				this.inputAmount = amount;
				this.member_type = type;
			},
			toPage() {
				uni.navigateTo({
					url: '/pages/about/zjhhr?member_type='+this.member_type+'&paytype=' + this.paytype
				});
			},
			isDefaultChange() {
				this.checked = !this.checked
				console.log(this.checked)
				// if (sldefault == true) {
				// 	this.isChecked = 1
				// } else {
				// 	this.isChecked = 0
				// }
			},
			doDeposit() {
				console.log(this.inputAmount)
				if (parseFloat(this.inputAmount).toString() == "NaN") {
					uni.showToast({
						title: '请选择充值金额',
						icon: 'none'
					});
					return;
				}
				if (this.inputAmount <= 0) {
					uni.showToast({
						title: '请输入大于0的金额',
						icon: 'none'
					});
					return;
				}
				if (this.inputAmount > 699) {
					uni.showToast({
						title: '高级合伙人名额有限 需联系客服向总部申请',
						icon: 'none',
						duration:1000
					});
					return;
				}
				if (parseFloat(this.inputAmount).toFixed(2) != parseFloat(this.inputAmount)) {
					uni.showToast({
						title: '最多只能输入两位小数哦~',
						icon: 'none'
					});
					return;
				}
				
				if(this.member_type==2){
					this.toPage()
				}
				
				// if (this.checked != true) {
				// 	uni.showToast({
				// 		title: '请确认同意合伙人协议',
				// 		icon: 'none'
				// 	});
				// 	return;
				// }
				//模板模拟支付，实际应用请调起微信/支付宝
			
			}
		},

	}
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.block {
		width: 94%;
		padding: 20upx 3%;
		margin-top: 20rpx;
		.title {
			
			font-size: 32rpx;
			font-weight: bold;
		}

		.price {
			color: #f45243;
			font-size: 34upx;
			font-weight: bold;
		}

		.content {
			.my {
				width: 100%;
				height: 80upx;
				display: flex;
				align-items: center;
				font-size: 28upx;
				color: #999;
			}

			.x-end {
				display: flex;
				-webkit-box-align: end;
				-webkit-align-items: flex-end;
				align-items: flex-end;

			}

			.x-bc {
				display: flex;
				-webkit-box-pack: justify;
				-webkit-justify-content: space-between;
				justify-content: space-between;
				-webkit-box-align: bottom;
				-webkit-align-items: bottom;
				align-items: bottom;

			}

			.y-start {
				display: flex;
				-webkit-box-orient: vertical;
				-webkit-box-direction: normal;
				-webkit-flex-direction: column;
				flex-direction: column;
				-webkit-box-align: start;
				-webkit-align-items: flex-start;
				align-items: flex-start;

			}
			.res {
				display: flex;
				// justify-content: space-between;
				align-items: center;
				height: 100upx;
				color: #999;
				font-size: 9px;
			}

			.item {

				.card-box {
					background: #fff;
					border: 2rpx solid #ececec;

					.title {
						color: #333;
					}

					.money-num {
						color: #F74B4B;
					}
				}
			}

			.item.on {

				.card-box {
					background: url() no-repeat;
					background-size: 100% 100%;
					box-shadow: 0px 0px 12rpx 9rpx rgba(#f8dca5, 0.82);

					.title {
						color: rgba(230, 184, 115, 1);
					}

					.money-num {
						color: rgba(230, 184, 115, 1);
					}
				}

			}

			.card-box {
				width: 77%;
				height: 140rpx;
				padding: 60rpx 8%;
				border-radius: 30rpx;
				overflow: hidden;
				z-index: 6;
				margin: 0 2% 50rpx;

				.left {
					display: flex;
					justify-content: space-between;
					height: 100%;
				}

				.cash-btn {
					width: 190rpx;
					height: 55rpx;
					line-height: 55rpx;
					background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
					border: 2rpx solid rgba(230, 184, 115, 1);
					box-shadow: 0px 7px 6px 0px rgba(229, 138, 0, 0.22);
					border-radius: 32rpx;
					padding: 0;
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: rgba(51, 51, 51, 1);
				}

				.title {
					font-size: 30rpx;
					font-family: Noto Sans S Chinese;
					font-weight: bold;
					line-height: 30rpx;
					width: 100%;
				}

				.money-num {
					font-size: 50rpx;
					font-family: FZHei-B01S;
					font-weight: 400;
					line-height: 72rpx;
				}

				.add {
					font-size: 22rpx;
					width: 400rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: rgba(230, 184, 115, 1);
					line-height: 26rpx;
				}
			}

			.pay-list {
				width: 100%;
				padding: 30rpx 0 150rpx;

				.row {
					width: 100%;
					height: 95upx;
					display: flex;
					align-items: center;

					.left {
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						align-items: center;

						image {
							width: 70upx;
							height: 70upx;
						}
					}

					.center {
						width: 100%;
						font-size: 30upx;
					}

					.right {
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						justify-content: flex-end;
					}
				}
			}
		}
	}


	.save {
		z-index: 999;
		position: fixed;
		width: 100%;
		background: #fff;
		padding: 20rpx 0;
		bottom: 0;
		box-shadow: 0 0 10px #eee;

		view {
			display: flex;
		}

		.btn {
			width: 90%;
			height: 100rpx;
			border-radius: 100rpx;
			color: #fff;
			background-color: #3cbdc5;
			justify-content: center;
			align-items: center;
			font-size: 30rpx;
			margin: 0 auto;
		}
	}
</style>
